package com.shj.util;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;

public class MyTimeUtil {

    public static String getNowTime() {
        LocalDateTime localDateTime = LocalDateTime.now();
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return df.format(localDateTime);
    }

    public static String getForString() {
        LocalDateTime localDateTime = LocalDateTime.now();
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
        return df.format(localDateTime);
    }

    public static LocalDateTime getNow() {
        return LocalDateTime.now();
    }

    public static boolean isCalendar(LocalDateTime now, String startTime, String endTime) {
        // 去点小数点
        String start = StringUtil.replaceZero(startTime);
        String end = StringUtil.replaceZero(endTime);
        String fm = "yyyy-MM-dd HH:mm:ss";
        LocalDateTime s = LocalDateTime.parse(start, DateTimeFormatter.ofPattern(fm));
        LocalDateTime e = LocalDateTime.parse(end, DateTimeFormatter.ofPattern(fm));
        return now.isBefore(e) && now.isAfter(s);
    }



}
